package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.domain.Student;
import com.itheima.domain.User;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = StudentService.class)
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<Student> findAll(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        List<Student> all = studentMapper.findAll();
        return new PageInfo<>(all);
    }

    @Override
    public void add(Student student) {
        studentMapper.saveStu(student);
    }

    @Override
    public void deleteStu(String number) {
        studentMapper.deleteStu(number);
    }

    @Override
    public void updateStu(Student student) {
        studentMapper.updateStu(student);
    }
}
